from django.shortcuts import render
from rest_framework.generics import ListAPIView
from article.models import FirstLevel, SecondLevel, Article
from article.serial import FirstLevelSerializer, SecondLevelSerializer, ArticleSerializer
from django_filters.rest_framework import DjangoFilterBackend

# Create your views here.
class FirstLevelListAPIView(ListAPIView):
    queryset = FirstLevel.objects.all()
    serializer_class = FirstLevelSerializer
    filter_backends = [DjangoFilterBackend]
    filterset_fields = ['category']

class SecondLevelListAPIView(ListAPIView):
    queryset = SecondLevel.objects.all()
    serializer_class = SecondLevelSerializer
    filter_backends = [DjangoFilterBackend]
    filterset_fields = ['first_level']

class ArticleListAPIView(ListAPIView):
    queryset = Article.objects.all()
    serializer_class = ArticleSerializer
    filter_backends = [DjangoFilterBackend]
    filterset_fields = ['second_level']
